package webdev.dto;

import java.util.ArrayList;

import android.os.Parcel;
import android.os.Parcelable;

public class DiaDiemDTO implements Parcelable {

	private int id;
	private String title;
	private String description;
	private String address;
	private String phoneNumber;
	private String image;
	private double lat;
	private double lng;
	
	private ArrayList<CommentDTO> comments;
	

	public static final Parcelable.Creator<DiaDiemDTO> CREATOR = new Creator<DiaDiemDTO>() {

		@Override
		public DiaDiemDTO[] newArray(int size) {
			return new DiaDiemDTO[size];
		}

		@Override
		public DiaDiemDTO createFromParcel(Parcel source) {
			return new DiaDiemDTO(source);
		}
	};

	public DiaDiemDTO() {
		setComments(new ArrayList<CommentDTO>());
	}

	public DiaDiemDTO(Parcel in) {
		id = in.readInt();
		title = in.readString();
		description = in.readString();
		address = in.readString();
		phoneNumber = in.readString();
		image = in.readString();
		lat = in.readDouble();
		lng = in.readDouble();
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getPhoneNumber() {
		return phoneNumber;
	}

	public void setPhoneNumber(String phoneNumber) {
		this.phoneNumber = phoneNumber;
	}

	public String getImage() {
		return image;
	}

	public void setImage(String image) {
		this.image = image;
	}

	public double getLat() {
		return lat;
	}

	public void setLat(double lat) {
		this.lat = lat;
	}

	public double getLng() {
		return lng;
	}

	public void setLng(double lng) {
		this.lng = lng;
	}

	@Override
	public int describeContents() {
		return 0;
	}

	@Override
	public void writeToParcel(Parcel dest, int flags) {
		dest.writeInt(id);
		dest.writeString(title);
		dest.writeString(description);
		dest.writeString(address);
		dest.writeString(phoneNumber);
		dest.writeString(image);
		dest.writeDouble(lat);
		dest.writeDouble(lng);
	}
	
	public void addComment(String idNamePlaces, String idUser, String content) {
		CommentDTO cm = new CommentDTO();
		cm.setNamePlace(idNamePlaces);
		cm.setUserName(idUser);
		cm.setContent(content);

		comments.add(cm);
	}

	public ArrayList<CommentDTO> getComments() {
		return comments;
	}

	public void setComments(ArrayList<CommentDTO> comments) {
		this.comments = comments;
	}
	
}
